﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Disposition : System.Web.UI.UserControl
{

    //public static string connString = "user id=portaluser;data source=172.25.9.26;initial catalog=VoiceNet_Focus;password=sqluser";

    //public SqlConnection conn = new SqlConnection(connString);

    protected void Page_Load(object sender, EventArgs e)
    {

        Response.Expires = -1;


        if (!IsPostBack)
        {
            try
            {
                ddlDispo.DataSource = ((DataAccess)Session["App"]).GetUsercodes();
                ddlDispo.DataTextField = ((DataAccess)Session["App"]).GetUsercodes().Columns["textField"].ColumnName.ToString();
                ddlDispo.DataValueField = ((DataAccess)Session["App"]).GetUsercodes().Columns["usercode"].ColumnName.ToString();
                ddlDispo.DataBind();
                ddlDispo.Items.Insert(0, new ListItem("", ""));
            }
            catch
            {
                ddlDispo.Items.Insert(0, new ListItem("Unable to get dispos", "Unable to get dispos"));
            }
            //LoadUsercodes();
        }
        else
        {
            //Session["App"] = App;
            //App = (DataAccess)Session["App"];
        }

    }

    //protected void Page_Unload(
    protected void ddlDispo_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            ((DataAccess)Session["App"]).PutCallData("webusercode", ddlDispo.SelectedItem.Value);
            //((DataAccess)Session["App"]).PutResult("webusercode", ddlDispo.SelectedItem.Value);
            ((DataAccess)Session["App"]).CommitCallData();
            //((DataAccess)Session["App"]).CommitResult();
            if (ddlDispo.SelectedIndex != 0)
            {
                btnDispo.Visible = true;
            }
            else 
            { 
                btnDispo.Visible = false; 
            }
            //Session["App"] = App;
            //UpdateResult();
        }
        catch
        {
        }
    }

    protected void btnDispo_Click(object sender, EventArgs e)
    {
        //HttpServerUtility temp;// = HttpServerUtility;
        //temp.Transfer("ScriptLoading.aspx");
        Response.Redirect("../DispositionComplete.aspx");
    }
}